import axios from 'axios'
import server from './server'

const baseUrl = server.baseUrl;
const startUrl = '/public/visit'

/**游客_文件上传*/
export const uploadImg = (data) => {
    let reqData = {
        file: data,
        path: data.name
    }
    return axios.post(`${baseUrl}${startUrl}/upload`, reqData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })    
}

/**游客_首页推荐*/
export const homePageRecommend = () => {
    return axios.get(`${baseUrl}${startUrl}/home/recommend`);   
}

/**游客_查看文章详情*/
export const articleDetail = (token, params) => {
    return axios.get(`${baseUrl}${startUrl}/articleDetail`, {
        params: params,
        headers: {
            'Authorization': token
        }
    })    
}

/**游客_获取所有文章类型*/
export const getAllType = () => {
    return axios.get(`${baseUrl}${startUrl}/getAllType`)    
}

/**游客_获取所有文章标签*/
export const getAllTag = () => {
    return axios.get(`${baseUrl}${startUrl}/getAllTag`)    
}

/**游客_根据文章获取标签*/
export const getTagByArt = (params) => {
    return axios.get(`${baseUrl}${startUrl}/getTagByArt`, {
        params: params
    })
}

/**游客_搜索文章*/
export const searchArticle = (token, params) => {
    return axios.get(`${baseUrl}${startUrl}/searchArticle`, {
        params: params ,
        headers: {
            'Authorization': token
        }
    })    
}

/**游客_搜索用户*/
export const searchUser = (params) => {
    return axios.get(`${baseUrl}${startUrl}/searchUser`, {
        params: params
    })    
}

/**游客_根据分类搜索文章*/
export const searchArtByType = (params) => {
    return axios.get(`${baseUrl}${startUrl}/searchArtByType`, {
        params: params
    })    
}

/**游客_根据标签搜索文章*/
export const searchArtByTag = (params) => {
    return axios.get(`${baseUrl}${startUrl}/searchArtByTag`, {
        params: params
    })    
}

/**游客_获取文章评论*/
export const getArticleComment = (params) => {
    return axios.get(`${baseUrl}${startUrl}/getArticleComment`, {
        params: params
    })    
}


/**游客_查看用户资料*/
export const checkUser = (data) => {
    return axios.get(`${baseUrl}${startUrl}/user/profile/${data}`, {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })    
}